package com.yt.controller;

import com.netflix.hystrix.contrib.javanica.annotation.DefaultProperties;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.yt.service.ProviderService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.concurrent.TimeUnit;

@RestController
//@DefaultProperties(defaultFallback = "fallback")
public class ComsumerController {

    @Resource
    ProviderService providerService;

//    @HystrixCommand
    @GetMapping("/message/{ren}")
    public String getMessage(@PathVariable("ren") int ren){
        return "客户端："+providerService.getMessage(ren);
    }

//    @HystrixCommand
    @GetMapping("/mes/{ren}")
    public String getMes(@PathVariable("ren") int ren){
        int i=3/0;
        return "客户端："+providerService.getMes(ren);
    }

    public String fallback(){
        return "出问题了，稍侯请重试";
    }
}
